package com.yal.service.fallback;


import com.yal.domian.Product;
import com.yal.service.ProductService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ProductServiceFallbackFactory implements FallbackFactory<ProductService> {

    @Override
    public ProductService create(Throwable throwable) {
        return new ProductService() {
            @Override
            public Product findByPid(Integer pid) {
                log.error("{}",throwable.getMessage());
                Product product = new Product();
                product.setPid(-100);
                product.setName("出现异常，进入容错类");
                return product;
            }
        };
    }
}
